import React, { Component } from 'react'
import { Route, Switch, Redirect } from 'react-router-dom'
import Home from './components/Home/Home'
import About from './components/About/About'
import MyNavLink from './components/MyNavLink'

export default class App extends Component {
  render() {
    return (
      <div id="root">
        <div>
          <div className="row">
            <div className="col-xs-offset-2 col-xs-8">
              <div className="page-header"><h2>React Router Demo</h2></div>
            </div>
          </div>
          <div className="row">
            <div className="col-xs-2 col-xs-offset-2">
              <div className="list-group">
                <MyNavLink to="/about/add">模糊匹配(默认)</MyNavLink>
                <MyNavLink to="/home/aa">精准匹配</MyNavLink>
              </div>
            </div>
            <div className="col-xs-6">
              <div className="panel">
                <div className="panel-body">
                  {/* 注册路由 */}
                  {/* 用Switch 包裹，匹配到组件后，不会在往下匹配 */}
                  <Switch>
                    <Route path="/about" component={About}></Route>
                    {/* exact为true，开启精准匹配 */}
                    <Route exact={true} path="/home" component={Home}></Route>
                    {/* 重定向 */}
                    <Redirect to="/home"></Redirect>
                  </Switch>

                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    )
  }
}
